//
//  StatusCellBottomView.swift
//  Sina
//
//  Created by maling  on 15/11/10.
//  Copyright © 2015年 maling . All rights reserved.
//

import UIKit

class StatusCellBottomView: UIView {

    
    //MARK: 构造方法
    override init(frame: CGRect) {
        super.init(frame: frame)
        
        //调用设置cell的底部视图
        setupUI()
    }

    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    
    
   
    // MARK: - 懒加载控件（三个按钮）
 /// 设置转发按钮
    private lazy var retweetedButton: UIButton = UIButton(title: "转发", fontSize: 12, color: UIColor.darkGrayColor(), imageName: "timeline_icon_retweet")
/// 设置评论按钮
    private lazy var commentButton: UIButton = UIButton(title: "评论", fontSize: 12, color: UIColor.darkGrayColor(), imageName: "timeline_icon_comment")
/// 设置点赞按钮
    private lazy var likeButton: UIButton = UIButton(title: "赞", fontSize: 12, color: UIColor.darkGrayColor(), imageName: "timeline_icon_unlike")
}

//MARK: - 设置界面 设置三个按钮
extension StatusCellBottomView {

    private func setupUI() {
    
        //设置底部视图的颜色，好区分
        backgroundColor = UIColor(white: 0.85, alpha: 1)
        
        // 设置三个按钮的能够交互
        
        
        // 1.添加控件
        addSubview(retweetedButton)
        addSubview(commentButton)
        addSubview(likeButton)
        
        // 2.设置控件的自动布局
        // 1> 设置转发的自动布局
        retweetedButton.snp_makeConstraints { (make) -> Void in
            make.top.equalTo(self.snp_top)
            make.left.equalTo(self.snp_left)
            make.bottom.equalTo(self.snp_bottom)
        }
        // 2> 设置评论按钮的自动布局
        commentButton.snp_makeConstraints { (make) -> Void in
            make.top.equalTo(retweetedButton.snp_top)
            make.left.equalTo(retweetedButton.snp_right)
            make.width.equalTo(retweetedButton.snp_width)
            make.height.equalTo(retweetedButton.snp_height)
        }
        // 3> 设置点赞按钮的自动布局
        likeButton.snp_makeConstraints { (make) -> Void in
            make.top.equalTo(commentButton.snp_top)
            make.left.equalTo(commentButton.snp_right)
            make.width.equalTo(commentButton.snp_width)
            make.height.equalTo(commentButton.snp_height)
            
            //另外设置一个定住三个按钮的自动布局（至关重要）
            make.right.equalTo(self.snp_right)
        }
    
        //4.设置分割视图
        // 创建两个分割线
        let leftView = sepView()
        let rightView = sepView()
        addSubview(leftView)
        addSubview(rightView)
        
        // 设置自动布局
        let viewWith = 0.5
        let scale = 0.5
        // 设置左边的分割线
        leftView.snp_makeConstraints { (make) -> Void in
            make.left.equalTo(retweetedButton.snp_right)
            make.centerY.equalTo(retweetedButton.snp_centerY)
            make.width.equalTo(viewWith)
            make.height.equalTo(retweetedButton.snp_height).multipliedBy(scale)
        }
        // 设置右边的分割线
        rightView.snp_makeConstraints { (make) -> Void in
            make.left.equalTo(commentButton.snp_right)
            make.centerY.equalTo(retweetedButton.snp_centerY)
            make.width.equalTo(viewWith)
            make.height.equalTo(retweetedButton.snp_height).multipliedBy(scale)
        }
        
        
        
    }
    
        // 创建一个函数返回值是view
        private func sepView() -> UIView {
        
            let view = UIView()
            view.backgroundColor = UIColor.darkGrayColor()//UIColor(white: 0.85, alpha: 1)
            return view
        }
        
    
    
    
    
}



























